package com.graduation.mathematics.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.graduation.mathematics.R;
import com.graduation.mathematics.bean.FunnyExam;

import java.util.List;

public class HistoryAdapter extends BaseExpandableAdapter<String, FunnyExam>{

    public interface OnItemViewClickLitener {
        void onAllViewClick(View view, int position);
        void onErrorViewClick(View view, int position);
    }

    private OnItemViewClickLitener myItemViewClickLitener;

    public void setOnItemViewClickLitener(OnItemViewClickLitener itemViewClickLitener) {
        this.myItemViewClickLitener = itemViewClickLitener;
    }

    public HistoryAdapter(Context mContext, int mGroupLayoutRes, int mChildLayoutRes, List<Unit<String, FunnyExam>> mData) {
        super(mContext, mGroupLayoutRes, mChildLayoutRes, mData);
    }

    @Override
    public void onBindView(FoldableViewHolder holder, int position) {
        if (holder instanceof GroupViewHolder) {
            TextView exam_name = holder.getView(R.id.exam_name);
            TextView downloadAll = holder.getView(R.id.download_all);
            downloadAll.setVisibility(View.GONE);
            TextView downloadError = holder.getView(R.id.download_error);
            downloadError.setVisibility(View.GONE);

            String name = (String) getItem(position);
            exam_name.setText(name);
//            tvSize.setText(directory.size+"");
        }

        if (holder instanceof ChildViewHolder) {
            TextView examNumber = holder.getView(R.id.exam_number);

            FunnyExam file = (FunnyExam) getItem(position);
            examNumber.setText(file.getQuestionId() + "");
        }
    }
}
